﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Elight.Repository.Interfaces
{
    /// <summary>
    /// 数据仓储泛型基础接口。
    /// </summary>
    /// <typeparam name="TEntity">业务实体类型</typeparam>
    public partial interface IBaseRepository<TEntity> where TEntity : class
    {
        /// <summary>
        /// 同步查询单个实体。
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        TEntity Get(int id);

        /// <summary>
        /// 异步查询单个实体。
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        Task<TEntity> GetAsync(int id);

        /// <summary>
        /// 同步查询所有实体。
        /// </summary>
        /// <returns></returns>
        IEnumerable<TEntity> GetAll();

        /// <summary>
        /// 异步查询所有实体。
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<TEntity>> GetAllAsync();

        /// <summary>
        /// 同步新增实体。
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        long Insert(TEntity entity);

        /// <summary>
        /// 异步新增实体。
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        Task<long> InsertAsync(TEntity entity);

        /// <summary>
        /// 同步批量新增实体。
        /// </summary>
        /// <param name="entities">实体集合</param>
        /// <returns></returns>
        long Insert(List<TEntity> entities);

        /// <summary>
        /// 异步批量新增实体。
        /// </summary>
        /// <param name="entity">实体集合</param>
        /// <returns></returns>
        Task<long> InsertAsync(List<TEntity> entities);

        /// <summary>
        /// 同步更新实体。
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        bool Update(TEntity entity);

        /// <summary>
        /// 异步更新实体。
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        Task<bool> UpdateAsync(TEntity entity);

        /// <summary>
        /// 同步批量更新实体。
        /// </summary>
        /// <param name="entities">实体集合</param>
        /// <returns></returns>
        bool Update(List<TEntity> entities);

        /// <summary>
        /// 异步批量更新实体。
        /// </summary>
        /// <param name="entities">实体集合</param>
        /// <returns></returns>
        Task<bool> UpdateAsync(List<TEntity> entities);

        /// <summary>
        /// 同步物理删除实体。
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        bool Delete(TEntity entity);

        /// <summary>
        /// 异步物理删除实体。
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        Task<bool> DeleteAsync(TEntity entity);

        /// <summary>
        /// 同步物理删除实体。
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        bool Delete(int id);

        /// <summary>
        /// 异步物理删除实体。
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        Task<bool> DeleteAsync(int id);

        /// <summary>
        /// 同步软删除实体。
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        bool DeleteSoft(int id);

        /// <summary>
        /// 异步软删除实体。
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        Task<bool> DeleteSoftAsync(int id);

        /// <summary>
        /// 同步物理删除所有实体。
        /// </summary>
        /// <returns></returns>
        bool DeleteAll();

        /// <summary>
        /// 异步物理删除所有实体。
        /// </summary>
        /// <returns></returns>
        Task<bool> DeleteAllAsync();
    }
}
